package cn.jhz.learn.blog.service.security.resource.photo.impl;

import cn.jhz.learn.blog.service.security.resource.photo.PhotoValidationAspect;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Aspect
@Component("photoValidationAspect")
public class PhotoValidtionAspectImpl implements PhotoValidationAspect {

    @Before(value = "execution(* cn.jhz.learn.blog.service.core.open.photo.AlbumService.getAlbum(Integer))&& args(photoSubfieldId)", argNames = "photoSubfieldId")
    public void getAlbum(Integer photoSubfieldId){
        //      validationService.photoSubfieldValid(photoSubfieldId);
    }

    @Before(value = "execution(* cn.jhz.learn.blog.service.core.open.photo.AlbumService.getAlbum(Integer,Integer))&& args(uid, photoSubfieldId)", argNames = "uid, photoSubfieldId")
    public void getAlbum(Integer uid, Integer photoSubfieldId){
        //  validationService.photoSubfieldValid(uid, photoSubfieldId);
    }

    //    @Before(value = "execution(* cn.jhz.learn.blog.service.core.open.photo.AlbumService.getSubfields(cn.jhz.learn.blog.vo.submit.ArticlePageView))&& args(pageView)", argNames = "pageView")
    //    public void getAlbumSubfields(@NotNull ArticlePageView pageView){
    //        if(!pageView.getBlog_id().isPresent())
    //            throw new ParamException("缺少条件!");
    //        else
    //            validationService.blogValid(pageView.getBlog_id().get());
    //    }
    //
    //    @Before(value = "execution(* cn.jhz.learn.blog.service.core.open.photo.AlbumService.getSubfields(Integer, cn.jhz.learn.blog.vo.submit.ArticlePageView))&& args(uid,pageView)", argNames = "uid,pageView")
    //    public void getAlbumSubfields(Integer uid, @NotNull ArticlePageView pageView){
    //        if(pageView.getBlog_id().isPresent())
    //            validationService.blogValid(uid, pageView.getBlog_id().get());
    //        else {
    //            validationService.uidValid(uid);
    //            pageView.setBlog_id(ValidationHolder.getCurrentUser().getId());
    //        }
    //    }
    //
    //    @Before(value = "execution(* cn.jhz.learn.blog.service.core.open.photo.AlbumService.getAlbums(cn.jhz.learn.blog.vo.submit.ArticlePageView))&& args(pageView)", argNames = "pageView")
    //    public void getAlbums(@NotNull ArticlePageView pageView){
    //        if(pageView.getBlog_id().isPresent() && pageView.getSubfield_id().isPresent())
    //            throw new ParamException("查询参数错误, 只能有一个关键条件!");
    //        else if(!pageView.getSubfield_id().isPresent() && !pageView.getBlog_id().isPresent())
    //            throw new ParamException("缺少条件, 至少有一个条件!");
    //        else if(pageView.getSubfield_id().isPresent())
    //            validationService.albumSubfieldValid(pageView.getSubfield_id().get());
    //        else
    //            validationService.blogValid(pageView.getBlog_id().get());
    //    }
    //
    //    @Before(value = "execution(* cn.jhz.learn.blog.service.core.open.photo.AlbumService.getAlbums(Integer,cn.jhz.learn.blog.vo.submit.ArticlePageView))&& args(uid,pageView)", argNames = "uid,pageView")
    //    public void getAlbums(Integer uid, @NotNull ArticlePageView pageView){
    //        if(pageView.getBlog_id().isPresent() && pageView.getSubfield_id().isPresent())
    //            throw new ParamException("查询参数错误, 只能有一个关键条件!");
    //        else if(pageView.getSubfield_id().isPresent())
    //            validationService.albumSubfieldValid(uid, pageView.getSubfield_id().get());
    //        else if(pageView.getBlog_id().isPresent())
    //            validationService.blogValid(uid, pageView.getBlog_id().get());
    //        else{
    //            validationService.uidValid(uid);
    //            pageView.setBlog_id(ValidationHolder.getCurrentUser().getId());
    //        }
    //    }

}
